package org.jimmy.tang.cglib.beancopy;

import java.util.HashMap;
import java.util.Map;

import net.sf.cglib.beans.BeanCopier;

/**
 * @author jimmy
 * 
 */
public class BeanCopyTest {
    public static void main(String[] args) {
        Person p1 = new Person("zhangsan", 10);
        Map<String, Person> map = new HashMap<String, Person>();
        map.put("test", p1);
        p1.setName("lisi");
        p1.setAge(11);
        // java.lang.NoClassDefFoundError:
        // net/sf/cglib/asm/util/TraceClassVisitor
        BeanCopier copier = BeanCopier
                .create(Person.class, Person.class, false);

        Person p2 = new Person();
        copier.copy(p1, p2, null);
        System.out.println(p2);
        p2.setName("p2's name");
        p2.setAge(200);
        System.out.println(p2);
        System.out.println(map.get("test"));
    }

}
